import request from '@/utils/request';

/**
 *商品订单列表
 */
export async function goodsOrderList(data) {
  const res = await request.post('/order/goodsOrderList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 发货
 */
export async function express(data) {
  const res = await request.post('/order/express', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改地址
export async function upAddress(data) {
  const res = await request.post('/order/upAddress', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
// 在线充值记录
export async function rechargeOrderList(data) {
  const res = await request.post('/order/rechargeOrderList', data);
  if (res.data.code === 0) {
    return res.data.data;
  } else {
    return res.data.data;
  }
}

// 同意退款
export async function confirmReturns(data) {
  const res = await request.post('/order/confirmReturns', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
  //   return Promise.reject(new Error(res.data.message));
}
// 购买商品
export async function createGoodsOrder(data) {
  const res = await request.post('/order/createGoodsOrder', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
  //   return Promise.reject(new Error(res.data.message));
}
// 余额充值
export async function rechargeOrder(data) {
  const res = await request.post('/order/rechargeOrder', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
// goodsInfo
export async function goodsOrderInfo(data) {
  const res = await request.post('/order/goodsOrderInfo', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
// 余额折扣
export async function consumptionDiscount(data) {
  const res = await request.post('/goods/consumptionDiscount', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
